Only keep the X11 version around in the backend.
<FILE>properties</FILE>
GdkAtom
gdk_text_property_to_utf8_list_for_display
-gdk_utf8_to_string_target
</SECTION>
<SECTION>
display_class->create_surface = _gdk_broadway_display_create_surface;
display_class->get_keymap = _gdk_broadway_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
- display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
display_class->get_monitor = gdk_broadway_display_get_monitor;
const guchar *text,
gint length,
gchar ***list);
-gchar *_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str);
GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
void _gdk_broadway_display_consume_all_input (GdkDisplay *display);
BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display,
return 0;
}
-gchar *
-_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str)
-{
- return g_strdup (str);
-}
const guchar *text,
gint length,
gchar ***list);
- gchar * (*utf8_to_string_target) (GdkDisplay *display,
- const gchar *text);
gboolean (*make_gl_context_current) (GdkDisplay *display,
GdkGLContext *context);
gint length,
gchar ***list);
-GDK_AVAILABLE_IN_ALL
-gchar *gdk_utf8_to_string_target (const gchar *str);
-
G_END_DECLS
#endif /* __GDK_PROPERTY_H__ */
->text_property_to_utf8_list (display, encoding, format, text, length, list);
}
-/**
- * gdk_utf8_to_string_target:
- * @str: a UTF-8 string
- *
- * Converts a UTF-8 string into the best possible representation
- * as a STRING. The representation of characters not in STRING
- * is not specified; it may be as pseudo-escape sequences
- * \x{ABCD}, or it may be in some other form of approximation.
- *
- * Returns: (nullable): the newly-allocated string, or %NULL if the
- * conversion failed. (It should not fail for any properly
- * formed UTF-8 string unless system limits like memory or
- * file descriptors are exceeded.)
- **/
-gchar *
-gdk_utf8_to_string_target (const gchar *str)
-{
- GdkDisplay *display = gdk_display_get_default ();
-
- return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str);
-}
-
display_class->create_surface_impl = _gdk_quartz_display_create_surface_impl;
display_class->get_keymap = _gdk_quartz_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
- display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
display_class->get_n_monitors = gdk_quartz_display_get_n_monitors;
display_class->get_monitor = gdk_quartz_display_get_monitor;
display_class->get_setting = gdk_quartz_display_get_setting;
const guchar *text,
gint length,
gchar ***list);
-gchar * _gdk_quartz_display_utf8_to_string_target (GdkDisplay *displayt,
- const gchar *str);
G_END_DECLS
#include "gdkproperty.h"
#include "gdkquartz.h"
-gchar *
-_gdk_quartz_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str)
-{
- /* FIXME: Implement */
- return NULL;
-}
-
static gint
make_list (const gchar *text,
gint length,
display_class->create_surface = _gdk_wayland_display_create_surface;
display_class->get_keymap = _gdk_wayland_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
- display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
const guchar *text,
gint length,
gchar ***list);
-gchar * _gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str);
void _gdk_wayland_display_create_seat (GdkWaylandDisplay *display,
guint32 id,
return nitems;
}
-/* This function has been copied straight from the x11 backend */
-static gchar *
-sanitize_utf8 (const gchar *src,
- gboolean return_latin1)
-{
- gint len = strlen (src);
- GString *result = g_string_sized_new (len);
- const gchar *p = src;
-
- while (*p)
- {
- if (*p == '\r')
- {
- p++;
- if (*p == '\n')
- p++;
-
- g_string_append_c (result, '\n');
- }
- else
- {
- gunichar ch = g_utf8_get_char (p);
-
- if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0)))
- {
- if (return_latin1)
- {
- if (ch <= 0xff)
- g_string_append_c (result, ch);
- else
- g_string_append_printf (result,
- ch < 0x10000 ? "\\u%04x" : "\\U%08x",
- ch);
- }
- else
- {
- char buf[7];
- gint buflen;
-
- buflen = g_unichar_to_utf8 (ch, buf);
- g_string_append_len (result, buf, buflen);
- }
- }
-
- p = g_utf8_next_char (p);
- }
- }
-
- return g_string_free (result, FALSE);
-}
-
-gchar *
-_gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str)
-{
- /* This is mainly needed when interfacing with old clients through
- * Xwayland, the STRING target could be used, and passed as-is
- * by the compositor.
- *
- * There's already some handling of this atom (aka "mimetype" in
- * this backend) in common code, so we end up in this vfunc.
- */
- return sanitize_utf8 (str, TRUE);
-}
-
}
}
-gchar *
-_gdk_win32_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str)
-{
- return g_strdup (str);
-}
-
gint
_gdk_win32_add_contentformat_to_pairs (const gchar *contentformat,
GArray *array)
display_class->get_keymap = _gdk_win32_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_win32_display_text_property_to_utf8_list;
- display_class->utf8_to_string_target = _gdk_win32_display_utf8_to_string_target;
display_class->make_gl_context_current = _gdk_win32_display_make_gl_context_current;
display_class->get_n_monitors = gdk_win32_display_get_n_monitors;
const guchar *text,
gint length,
gchar ***list);
-gchar *_gdk_win32_display_utf8_to_string_target (GdkDisplay *display, const gchar *str);
gboolean _gdk_win32_keymap_has_altgr (GdkWin32Keymap *keymap);
guint8 _gdk_win32_keymap_get_active_group (GdkWin32Keymap *keymap);
display_class->create_surface = _gdk_x11_display_create_surface;
display_class->get_keymap = gdk_x11_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
- display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
const guchar *text,
gint length,
gchar ***list);
-gchar * _gdk_x11_display_utf8_to_string_target (GdkDisplay *displayt,
- const gchar *str);
+char * gdk_x11_utf8_to_string_target (const char *utf8_str,
+ gboolean return_latin1);
void _gdk_x11_device_check_extension_events (GdkDevice *device);
return res;
}
-/* The specifications for COMPOUND_TEXT and STRING specify that C0 and
- * C1 are not allowed except for \n and \t, however the X conversions
- * routines for COMPOUND_TEXT only enforce this in one direction,
- * causing cut-and-paste of \r and \r\n separated text to fail.
- * This routine strips out all non-allowed C0 and C1 characters
- * from the input string and also canonicalizes \r, and \r\n to \n
- */
-static gchar *
-sanitize_utf8 (const gchar *src,
- gboolean return_latin1)
-{
- gint len = strlen (src);
- GString *result = g_string_sized_new (len);
- const gchar *p = src;
-
- while (*p)
- {
- if (*p == '\r')
- {
- p++;
- if (*p == '\n')
- p++;
-
- g_string_append_c (result, '\n');
- }
- else
- {
- gunichar ch = g_utf8_get_char (p);
-
- if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0)))
- {
- if (return_latin1)
- {
- if (ch <= 0xff)
- g_string_append_c (result, ch);
- else
- g_string_append_printf (result,
- ch < 0x10000 ? "\\u%04x" : "\\U%08x",
- ch);
- }
- else
- {
- char buf[7];
- gint buflen;
-
- buflen = g_unichar_to_utf8 (ch, buf);
- g_string_append_len (result, buf, buflen);
- }
- }
-
- p = g_utf8_next_char (p);
- }
- }
-
- return g_string_free (result, FALSE);
-}
-
-gchar *
-_gdk_x11_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str)
-{
- return sanitize_utf8 (str, TRUE);
-}
-
/**
* gdk_x11_display_utf8_to_compound_text:
* @display: (type GdkX11Display): a #GdkDisplay
need_conversion = !g_get_charset (&charset);
- tmp_str = sanitize_utf8 (str, FALSE);
+ tmp_str = gdk_x11_utf8_to_string_target (str, FALSE);
if (need_conversion)
{
if (utf8_is_latin1 (utf8_str))
{
prop_type = XA_STRING;
- prop_text = _gdk_x11_display_utf8_to_string_target (display, utf8_str);
+ prop_text = gdk_x11_utf8_to_string_target (utf8_str, TRUE);
prop_length = prop_text ? strlen (prop_text) : 0;
prop_format = 8;
is_compound_text = FALSE;
}
}
+/* The specifications for COMPOUND_TEXT and STRING specify that C0 and
+ * C1 are not allowed except for \n and \t, however the X conversions
+ * routines for COMPOUND_TEXT only enforce this in one direction,
+ * causing cut-and-paste of \r and \r\n separated text to fail.
+ * This routine strips out all non-allowed C0 and C1 characters
+ * from the input string and also canonicalizes \r, and \r\n to \n
+ */
+char *
+gdk_x11_utf8_to_string_target (const char *utf8_str,
+ gboolean return_latin1)
+{
+ gint len = strlen (utf8_str);
+ GString *result = g_string_sized_new (len);
+ const gchar *p = utf8_str;
+
+ while (*p)
+ {
+ if (*p == '\r')
+ {
+ p++;
+ if (*p == '\n')
+ p++;
+
+ g_string_append_c (result, '\n');
+ }
+ else
+ {
+ gunichar ch = g_utf8_get_char (p);
+
+ if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0)))
+ {
+ if (return_latin1)
+ {
+ if (ch <= 0xff)
+ g_string_append_c (result, ch);
+ else
+ g_string_append_printf (result,
+ ch < 0x10000 ? "\\u%04x" : "\\U%08x",
+ ch);
+ }
+ else
+ {
+ char buf[7];
+ gint buflen;
+
+ buflen = g_unichar_to_utf8 (ch, buf);
+ g_string_append_len (result, buf, buflen);
+ }
+ }
+
+ p = g_utf8_next_char (p);
+ }
+ }
+
+ return g_string_free (result, FALSE);
+}
+
static GConverterResult
gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv,
const void *inbuf,
gchar *tmp, *latin1;
tmp = g_strndup (inbuf, inbuf_size);
- latin1 = gdk_utf8_to_string_target (tmp);
+ latin1 = gdk_x11_utf8_to_string_target (tmp, TRUE);
g_free (tmp);
if (latin1)
{